package ltd.followkba;


import android.content.Intent;
import android.view.View;

import com.kcbsdk.AFileBase;
import com.kcbsdk.ARoomType;
import com.kcbsdk.AUserBase;
import com.kcbsdk.MyManage.AUserFileType;
import com.kcbsdk.MyManage.AUserInfo;
import com.kcbsdk.MyWorks.AFileInfo;
import com.kcbsdk.MyWorks.AFileType;
import com.kcbsdk.MyWorks.AGiftBean;
import com.kcbsdk.MyWorks.AObbligInfo;
import com.kcbsdk.MyWorks.APhotoInfo;
import com.kcbsdk.MyWorks.ARecordInfo;
import com.kcbsdk.MyWorks.ATakeInfo;

import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.util.List;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

import ltd.advskin.C;
import ltd.advskin.MRAM;
import ltd.advskin.MSKIN;
import ltd.advskin.P;
import ltd.advskin.VARIA;
import ltd.advskin.base.BaseInput;
import ltd.advskin.base.KcListener;
import ltd.advskin.base.KcLoadListener;
import ltd.advskin.base.KcNoneListener;
import ltd.advskin.base.KcTwoListener;
import ltd.advskin.base.MPAGE;
import ltd.advskin.task.TaskDownload;
import ltd.advskin.view.KcBtnImage;
import ltd.followkba.page.EditTextPage;
import ltd.followkba.page.EditUploadPage;
import ltd.followkba.page.LocalPhotoPage;
import ltd.followkba.page.LoginManagePage;
import ltd.followkba.page.PhotoWorksPage;
import ltd.followkba.page.SearchUserPage;
import ltd.followkba.page.SelectUserPage;
import ltd.followkba.page.SettingPage;
import ltd.followkba.page.TipsPage;
import ltd.followkba.page.UploadListPage;
import ltd.followkba.task.BAppUser;
import ltd.followkba.task.BAppWorks;
import ltd.followkba.task.BDbsAccount;
import ltd.followkba.task.BFileBase;
import ltd.followkba.task.BRankInfo;
import ltd.followkba.task.BUploadPlan;
import ltd.followkba.task.BWriteLock;
import ltd.followkba.task.TaskEach;
import ltd.followkba.task.TaskService;
import ltd.followkba.page.UserHomePage;
import ltd.followkba.task.LogTyp;
import ltd.followkba.task.WorksQueue;
import ltd.obbphoto.MOBBW;
import main.MAPI;

import static ltd.advskin.MSKIN.MLOGE;
import static ltd.advskin.MSKIN.MSTRING;
import static ltd.advskin.MSKIN.MTOAST;
import static ltd.advskin.utils.AdvBitmap.*;
import static main.MAPI.mMyUtils;


/**
 * Created by Administrator on 2017/11/1.
 */

public class MAPP {
    public static boolean isChangThemeStyle;

    public static KcNoneListener mKcNoneListener;
    public static KcNoneListener mRunStatePage;
    public static boolean threadStop;
    public static int gManageLogin;

    public static int gStartDateTime;
    public static volatile BWriteLock mBLock32;
    public static volatile BWriteLock mBLock33;

    public static BDbsAccount mBDbsAccount;
    public static BDbsAccount mManageAccount;
    public volatile static byte[] mWorksType;
    public volatile static String[] mWorksName;
    public static List<BAppUser> mSearch;
    public static AGiftBean[] mKcAGiftBean;
    public static BRankInfo[] mKcBRankInfo;
    public static String gErrorManage;
    public volatile static TaskEach[][] mTaskEach;
    public volatile static Object mLockTask;


    public static int[] gSuccessQty;
    public static int gSuccesslAll;


    public volatile static boolean openAarPage;             // 打开SKIN或者OBB库的页面，需要使用 MSKIN.onTimer();


    public static void MLOG(String text) {
        MSTRING(text);
    }

    public static void MLOG_FILE(BDbsAccount bDbsAccount, String title, String text) {
        BFileBase bFileBase = new BFileBase();
        bFileBase.WorksName = title;
        bFileBase.Text = text;
        MDBS.setDoneLog(bDbsAccount, LogTyp.LOG_FILE, bFileBase);
    }

    public static boolean lockWrite32(String text){                     // text!=null为锁定/text==null为解锁，解锁与锁定必须成对出现
        synchronized(mBLock32) {                                       // 使用对象自带的锁
            if (text != null ) {
                if (MAPP.mBLock32.Text == null) {
//                    MLOGE("mBLock32 A " + text);
                    MAPP.mBLock32.Text = text;                              // App32写评论等需要指定账号的动作
                    MAPP.mBLock32.Tick = System.currentTimeMillis();
                    return true;
                }
            }else {                                                     // 解锁App32写评论等需要指定账号的动作
//                MLOGE("mBLock32 B "+MAPP.mBLock32.Text);
                MAPP.mBLock32.Text = null;
            }
        }
        return false;
    }
    public static boolean lockWrite33(String text){                     // text!=null为锁定/text==null为解锁 解锁与锁定必须成对出现
        synchronized(mBLock33) {                                       // 使用对象自带的锁
            if (MAPP.mBLock33.Text == null) {
                MAPP.mBLock33.Text = text;                               // App33写评论等需要指定账号的动作
                MAPP.mBLock33.Tick = System.currentTimeMillis();
                return true;
            }else {                                                     // 解锁App33写评论等需要指定账号的动作
                MAPP.mBLock33.Text = null;
            }
        }
        return false;
    }
    public static void setTaskPause(boolean isPause){
        WorksQueue.setPause(isPause);
        if (MAPP.mTaskEach != null) {
            synchronized (MAPP.mLockTask) {
                for (int tabTyp = 0; tabTyp < MAPP.mWorksType.length; tabTyp++) {
                    if (MAPP.mTaskEach[tabTyp] != null && MAPP.mWorksType[tabTyp] < 32) {           // 只有App32全面暂停
                        for (int index = 0; index < MAPP.mTaskEach[tabTyp].length; index++) {      // 打开各自
                            MAPP.mTaskEach[tabTyp][index].setPause(isPause);
                        }
                    }
                }
            }
        }
    }
    public static int getWorksTypeIndex(int worksType) {
        if (MAPP.mWorksType != null) {
            for (int index = 0; index < MAPP.mWorksType.length; index++){
                if (worksType == MAPP.mWorksType[index]){
                    return index;
                }
            }
            return 0;
        }
        return 0;
    }

    public static byte[] makeArrayType(String[] strings){
        byte[] outData = new byte[strings.length];
        for (int index = 0; index < strings.length; index++){
            int g4Local_1 = MAPI.ASCII_HEX(strings[index].charAt(0));
            int g4Local_2 = MAPI.ASCII_HEX(strings[index].charAt(1));
            outData[index] = (byte)((g4Local_1 << 4) | g4Local_2);
        }
        return outData;
    }
    public static String formatSecond(long millisecond) {
        return (millisecond < 1000) ? String.format("%sms", millisecond) : String.format("%.1f秒", (float)millisecond/1000.f);
    }

    public static String getUser(AUserInfo aUserInfo, int worksType){
        return String.format("作%s粉%s关%s欣%s %s", aUserInfo.WorksQty[worksType], aUserInfo.FansQty, aUserInfo.CareQty, aUserInfo.ListenQty, aUserInfo.Gender);
    }
    public static String getUser(BAppUser bAppUser){
        return String.format("作%s粉%s关%s欣%s %s", bAppUser.WorksQty, bAppUser.FansQty, bAppUser.CareQty, bAppUser.ListenQty, bAppUser.Gender);
    }
    public static String getWorks(AFileInfo aFileInfo){
        return String.format("评%s赞%s欣%s下%s享%s礼%s", aFileInfo.CommentQty, aFileInfo.LikeQty, aFileInfo.ListenQty, aFileInfo.DownloadQty, aFileInfo.ShareQty, aFileInfo.GiftQty);
    }
    public static String getWorks(BAppWorks bAppWorks){
        return String.format("评%s赞%s欣%s享%s花%s钱%s免%s", bAppWorks.CommentQty, bAppWorks.LikeQty, bAppWorks.ListenQty, bAppWorks.ShareQty, bAppWorks.GiftQty, bAppWorks.MoneyQty, bAppWorks.FreeQty);
    }
    public static String getLoginFlag(int worksType){
        switch (worksType){
            case 33: return "169785298:45aaa566eea3781";//"75937464,96555c5933e7bbb";//"139176368,1d0a135c433df39";//"75937464,96555c5933e7bbb";
            default: return "";
        }
    }
    public static int getDefaultUserID(int worksType){
        switch (worksType){
            case 33: return 75937464;
            default: return 0;
        }
    }
    public static String getNeatName(int limitSize, String name){       // 整洁的名字
        int length = name.length();
        boolean isChinese = false;
        for (int index = 0; index < length; index++){
            int chr = name.charAt(index) & 0xffff;
            if (!isChinese && (chr >= 0x4e00 && chr <= 0x9fa5)){
                isChinese = true;
            }else if (isChinese && (chr < 0x4e00 || chr > 0x9fa5)){    // 从有中文到没有中文
                if (chr >= '0' && chr <= '9'){       // ascii
                }else if (chr >= 'A' && chr <= 'Z'){
                }else if (chr >= 'a' && chr <= 'z'){
                }else {
                    return name.substring(0, index);
                }
            }
            if (index > limitSize && limitSize > 0){
                return name.substring(0, index);
            }
        }
        return name;
    }

    public static void MTOAST(final String text){
        if (MRAM.mActivity != null) {
            MRAM.mActivity.runOnUiThread(new Runnable() {
                public void run() {
                    MSKIN.MTOAST(text);
                }
            });
        }
    }
    public static void showWorksName(BAppWorks bAppWorks, View view) {
        if (bAppWorks != null) {
            showWorksName(bAppWorks.WorksName, bAppWorks.WorksType, bAppWorks.IsOriginal, bAppWorks.IsVideo, view);
        }
    }
    public static void showWorksName(String text, int worksType, boolean original, boolean video, View view) {
        if (original) {
            text = String.format("%s[P%d]", text, (worksType == 39) ? P.orig_1 : P.orig_0);
        }
        if (video) {
            text = String.format("%s[P%d]", text, P.video_0);
        }
        MSKIN.setText(text, view);
    }
    public static void showUserHead(String fileName, AUserBase aUserBase, View view){
        if (fileName == null){
            MSKIN.showUserHead(AUserFileType.IMG_SMALL, aUserBase, view);
        }else if (MAPI.IS_FILE_DONE(fileName)){
            int round = 8;
            int bgC3Color = C3_BG_GIRL;                              // 背景女用户颜色
            KcBtnImage kcBtnImage = (KcBtnImage) view;
            kcBtnImage.setBackground(C3_BGC_TYPE1 | bgC3Color | round, 0, 64, 64);
            kcBtnImage.setBitmap(C3_FG_NORMAL | (round / 2), fileName, C.user_head);
        }
    }
    public static void showUserHead(String fileName, View view){
        if (MAPI.IS_FILE_DONE(fileName)){
            int round = 8;
            int bgC3Color = C3_BG_GIRL;                              // 背景女用户颜色
            KcBtnImage kcBtnImage = (KcBtnImage) view;
            kcBtnImage.setBackground(C3_BGC_TYPE1 | bgC3Color | round, 0, 64, 64);
            kcBtnImage.setBitmap(C3_FG_NORMAL | (round / 2), fileName, C.user_head);
        }
    }
    public static void showUserName(String userName, int worksType, AUserBase aUserBase, View view){
        if (!MAPI.isEmpty(userName)) {
            MSKIN.setText(userName, view);
            return;
        }
        if (worksType < 0x20 && aUserBase.UserID != 0){
            userName = mMyUtils.getNickName(aUserBase);
            MSKIN.setText(userName, view);
        }
        if (MAPI.isEmpty(userName)){
            MSKIN.setText("没名字", view);
        }
    }
    public static void showWorksCover(AFileBase aFileBase, String fileName, View view) {
        if (aFileBase instanceof BAppWorks){
            BAppWorks bAppWorks = (BAppWorks) aFileBase;
            if (bAppWorks.WorksType < 32 && aFileBase.UserID != 0 && aFileBase.FileID != 0){
                fileName = getWorksCover(aFileBase);
                MSKIN.showWorksCover(fileName, view);
                return;
            }
        }
//        if (aFileBase != null){
//            fileName = getWorksCover(aFileBase);
//            MSKIN.showWorksCover(fileName, view);
//            return;
//        }
        MSKIN.showWorksCover(fileName, view);
    }
    public static String getWorksCover(final AFileBase aFileBase) {
        String fileName = null;
        if (aFileBase instanceof AObbligInfo) {
            fileName = ((AObbligInfo)aFileBase).CoverFile;
            if (!MAPI.IS_FILE_DONE(fileName)) {
                AObbligInfo aObbligInfo = (AObbligInfo)aFileBase;
                if (!MAPI.isEmpty(aObbligInfo.CoverUrl)) {
                    if (MSKIN.downloadUrlFile(aObbligInfo.CoverUrl, aObbligInfo.CoverFile, (KcTwoListener)null)) {
                        return aObbligInfo.CoverFile;
                    }
                } else {
                    MLOGE("getWorksCover 没有有对应的url");
                }
            }
        } else if (aFileBase instanceof APhotoInfo) {
            fileName = ((APhotoInfo)aFileBase).FileName;
        } else if (aFileBase instanceof ARecordInfo) {
            fileName = ((ARecordInfo)aFileBase).CoverFile;
        } else if (aFileBase instanceof ATakeInfo) {
            fileName = ((ATakeInfo)aFileBase).CoverFile;
        } else if (aFileBase instanceof BAppWorks) {
            BAppWorks bAppWorks = (BAppWorks)aFileBase;
            AFileType aFileType = AFileType.FILE_COVER_PHOTO;//MAPI.mMyUtils.getPhotoFileType(bAppWorks);
            if (aFileType != null) {
                fileName = MAPI.mMyUtils.getWorksFileName(aFileType, aFileBase, MRAM.gsCachePath);
                MLOG(String.format("showWorksCover getWorksCover BB %s_%s", MAPI.IS_FILE_DONE(fileName), fileName));
                if (!MAPI.IS_FILE_DONE(fileName) || MAPI.mMyWorks.isFileNeedRefresh(ARoomType.ROOM_WORK.getType(), aFileType.getType(), bAppWorks.UserID, bAppWorks.FileID)) {
                    MAPI.DEL_FILE_DONE(fileName);
                    MLOG(String.format("showWorksCover getWorksCover CC %s_%s", MAPI.IS_FILE_DONE(fileName), fileName));
                    if (VARIA.mCoverDownload == null) {
                        VARIA.mCoverDownload = new TaskDownload();
                    }

                    VARIA.mCoverDownload.downloadWorksFile(aFileType, aFileBase, fileName, new KcLoadListener() {
                        public void onMessage(int percent, String fileName, AFileBase aFileBase, Object object) {
                                if (percent == 102 || percent == 103) {
                                    MLOG(String.format("showWorksCover getWorksCover DD %s_%s", MAPI.IS_FILE_DONE(fileName), fileName));
                                    if (MAPI.IS_FILE_DONE(fileName)) {
                                        int roomType = ARoomType.ROOM_WORK.getType();
                                        int fileType = (int)object;
                                        MAPI.mMyWorks.setFileRefreshDone(roomType, fileType, aFileBase.UserID, aFileBase.FileID);
                                        MSKIN.setEventDataRefresh(1);
                                    }
                            }

                        }
                    });
                }

                if (aFileType == AFileType.FILE_COVER_MPP) {
                    MLOG(String.format("showWorksCover getWorksCover EE %s_%s", MAPI.IS_FILE_DONE(fileName), bAppWorks.MppFile));
                    if (MAPI.IS_FILE_DONE(fileName) && bAppWorks.MppFile == null) {
                        bAppWorks.MppFile = MAPI.READ_MPP_FILE(fileName);
                    }

                    if (bAppWorks.MppFile != null) {
                        return bAppWorks.MppFile;
                    }
                }

                MLOG(String.format("showWorksCover getWorksCover FF %s_%s_%04x_%s_%s", aFileType, aFileBase.UserID, aFileBase.FileID, fileName, bAppWorks.MppFile));
            }
        }

        return MAPI.IS_FILE_DONE(fileName) ? fileName : null;
    }

    public static String textsToText(String[] texts){
        if (texts != null && texts.length > 0){
            StringBuffer stringBuffer = new StringBuffer();
            for (int index = 0; index < texts.length; index++){
                stringBuffer.append(texts[index]);
                stringBuffer.append("\n");
            }
            return stringBuffer.toString();
        }
        return "";
    }
    public static boolean checkOverHour(int dataTime, int hour) {       // 检查超过规定的小时返回true
        int nowTime = mMyUtils.getCurrentDate();
//        nowTime = (nowTime)
        if ((nowTime >> 16) != (dataTime >> 16)) {
            return true;
        }
        nowTime = (nowTime & 0xffff) / (60 * 30);                       // 化成小时
        dataTime = (dataTime & 0xffff) / (60 * 30);                     // 化成小时
        if ((dataTime + hour) < nowTime){
            return true;
        }
        return false;
    }


    public static void startTaskService(boolean start) {
        if (start) {
            Intent intent = new Intent(MRAM.mContext, TaskService.class);
            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
                MRAM.mContext.startForegroundService(intent);
            }else {
                MRAM.mContext.startService(intent);
            }
        } else {
            MRAM.mContext.stopService(new Intent(MRAM.mContext, TaskService.class));
        }
    }
    /////////////////////////////////////////////////////////////////////////////////////
    ////Page页面/////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////


    public static void startUserHomePage(BAppUser bAppUser, boolean selectWorks){
        if (bAppUser != null) {
            if (bAppUser.WorksType > 32 || selectWorks) {
                UserHomePage userHomePage = new UserHomePage();
                userHomePage.mBaseInput = new BaseInput(bAppUser, selectWorks);
                MPAGE.startBasePage(userHomePage);
            } else {
//if (bAppUser.UserID == 0) bAppUser.UserID = MAPI.STRING_DEC32(bAppUser.UserIdS);
                MOBBW.startWorksHomePage(bAppUser.WorksType, bAppUser, false);
            }
        }
    }
    public static void startSettingPage(){                  // 系统设置
        SettingPage settingPage = new SettingPage();
        MPAGE.startBasePage(settingPage);
    }
    public static void startCommentTextPage(LogTyp logTyp){                  // 评论文字
        EditTextPage editTextPage = new EditTextPage();
        editTextPage.mBaseInput = new BaseInput(logTyp);
        MPAGE.startBasePage(editTextPage);
    }
    public static void startPhotoWorksPage(BAppUser bAppUser){
        PhotoWorksPage photoWorksPage = new PhotoWorksPage();
        photoWorksPage.mBaseInput = new BaseInput(bAppUser);
        MPAGE.startBasePage(photoWorksPage);
    }
    public static void startLocalPhotoPage(){
        LocalPhotoPage localPhotoPage = new LocalPhotoPage();
        localPhotoPage.mBaseInput = new BaseInput();
        MPAGE.startBasePage(localPhotoPage);
    }
    public static void startUploadListPage(){
        UploadListPage uploadListPage = new UploadListPage();
        uploadListPage.mBaseInput = new BaseInput();
        MPAGE.startBasePage(uploadListPage);
    }
    public static void startSelectUserPage(boolean noTab){
        SelectUserPage selectUserPage = new SelectUserPage();
        selectUserPage.mBaseInput = new BaseInput(noTab);
        MPAGE.startBasePage(selectUserPage);
    }
    public static void startSearchUserPage(byte appType){
        SearchUserPage searchUserPage = new SearchUserPage();
        searchUserPage.mBaseInput = new BaseInput(appType);
        MPAGE.startBasePage(searchUserPage);
    }
    public static void startEditUploadPage(BUploadPlan bUploadPlan){
        EditUploadPage editUploadPage = new EditUploadPage();
        editUploadPage.mBaseInput = new BaseInput(bUploadPlan);
        MPAGE.startBasePage(editUploadPage);
    }
    public static void startLoginManagePage(){
        LoginManagePage loginManagePage = new LoginManagePage();
        MPAGE.startBasePage(loginManagePage);
    }
    public static void startTipsPage(){
        TipsPage tipsPage = new TipsPage();
        MPAGE.startBasePage(tipsPage);
    }
    public static void startThirdPartyActivity(int type) {     // 第三方页面处理
        startThirdPartyActivity(type, null, null);
    }
    public static void startThirdPartyActivity(int type, String[] strArray, KcListener kcListener){     // 第三方页面处理
//        VARIA.mSaveKcListener = kcListener;
//        Intent intent = new Intent(MRAM.mActivity, ThirdPartyActivity.class);
//        Bundle bundle = new Bundle();
//        bundle.putInt("type", type);
//        bundle.putStringArray("strArray", strArray);
//        intent.putExtras(bundle);
//        MRAM.mActivity.startActivityForResult(intent,10017);
    }
    public static void startCnkcPopWindow(int type, KcTwoListener kcTwoListener){
    }

    public static String formatRmbMoney(int value){
        if ((value % 100) == 0){
            return String.format("%d", value / 100);  // 没有带小数点的
        }
        return String.format("%d.%02d", value / 100, value % 100);  // 带小数点的
    }
    public static double convertToDouble(String number) {  // 单位转化
        if (!MAPI.isEmpty(number)) {
            try {
                return Integer.parseInt(number);
            } catch (Exception e) {
            }
        }
        return 0;
    }
    public static final int[] item_user_select = new int[]{
            R.layout.item_user_select, 5,
            R.id.kbiSelectUser, R.id.kbiHeadUser, R.id.tvNameUser, R.id.tvStateUser, R.id.kbtDeleteUser,
    };
    public static String tabRankChangBa[] = {
            "全国",
            // 华南地区 广东、广西、海南、香港、澳门
            "广东",	"广州",	"深圳",	"珠海",	"汕头",	"韶关",	"佛山",	"江门",	"湛江",	"茂名",
            "肇庆",	"惠州",	"梅州",	"汕尾",	"河源",	"阳江",	"清远",	"东莞",	"中山",	"潮州",
            "揭阳",	"云浮",
            "广西",	"南宁",	"柳州",	"桂林",	"梧州",	"北海",	"防城港",	"钦州",	"贵港",	"玉林",
            "百色",	"贺州",	"河池",	"来宾",	"崇左",
            "海南",	"海口",	"文昌",	"三亚",	"五指山",	"琼海",	"儋州",	"万宁",
            "香港",	"澳门",
            // 华东地区	上海、江苏、浙江、安徽、福建、江西、山东、台湾
            "上海",
            "江苏",	"南京",	"苏州",	"无锡",	"常州",	"扬州",	"泰州",	"连云港",	"徐州",	"淮安",
            "宿迁",	"盐城",	"南通",	"镇江",
            "浙江",	"嘉兴",	"温州",	"金华",	"绍兴",	"湖州",	"宁波",	"杭州",	"舟山",	"台州",
            "衢州",	"丽水",
            "福建",	"厦门",	"泉州",	"三明",	"南平",	"龙岩",	"漳州",	"宁德",	"莆田",	"福州",
            "江西",	"南昌",	"景德镇",	"九江",	"萍乡",	"新余",	"鹰潭",	"赣州",	"宜春",	"上饶",
            "吉安",	"抚州",
            "山东",	"济南",	"青岛",	"淄博",	"枣庄",	"东营",	"烟台",	"潍坊",	"济宁",	"泰安",
            "威海",	"日照",	"滨州",	"德州",	"聊城",	"临沂",	"菏泽",	"莱芜",
            "台湾",
            // 华中地区	河南，湖北，湖南
            "湖北",	"武汉",	"黄石",	"十堰",	"荆州",	"宜昌",	"襄阳",	"鄂州",	"荆门",	"孝感",
            "黄冈",	"咸宁",	"随州",	"恩施",	"仙桃",	"天门",	"潜江",	"神农架",
            "湖南",	"长沙",	"株洲",	"湘潭",	"衡阳",	"邵阳",	"岳阳",	"常德",	"张家界",	"益阳",
            "郴州",	"永州",	"怀化",	"娄底",	"湘西",
            "河南",	"郑州",	"洛阳",	"焦作",	"安阳",	"平顶山",	"漯河",	"鹤壁",	"新乡",	"南阳",
            "济源",	"商丘",	"濮阳",	"许昌",	"开封",	"三门峡",	"信阳",	"驻马店",	"周口",
            // 华北地区	京、津、河、山西、内蒙古
            "北京",	"天津",
            "河北",	"石家庄",	"邯郸",	"保定",	"承德",	"唐山",	"廊坊",	"沧州",	"衡水",	"邢台",
            "秦皇岛",
            "山西",	"太原",	"大同",	"阳泉",	"长治",	"晋城",	"朔州",	"晋中",	"运城",	"忻州",
            "临汾",	"吕梁",
            "内蒙古",	"呼和浩特","呼伦贝尔","兴安",	"通辽",	"赤峰",	"锡林郭勒","乌兰察布","包头",	"鄂尔多斯",
            "巴彦淖尔","乌海",	"阿拉善",
            // 西北地区	宁夏、新疆，青海 、陕西 、甘肃
            "宁夏",	"吴忠",	"中卫",	"固原",	"银川",	"石嘴山",
            "青海",	"西宁",	"黄南",	"果洛",	"玉树",
            "陕西",	"西安",	"咸阳",	"商洛",	"安康",	"汉中",	"延安",	"渭南",	"铜川",	"榆林",
            "甘肃",	"兰州",	"天水",	"白银",	"平凉",	"庆阳",	"陇南",	"定西",	"金昌",	"武威",
            "张掖",	"酒泉",	"嘉峪关",	"临夏",	"甘南",
            // 西南地区	四川、重庆，贵州 、云南 、西藏
            "四川",	"成都",	"自贡",	"攀枝花",	"泸州",	"德阳",	"绵阳",	"广元",	"遂宁",	"内江",
            "乐山",	"南充",	"宜宾",	"广安",	"达州",	"眉山",	"雅安",	"巴中",	"资阳",	"阿坝",
            "甘孜",	"凉山",
            "重庆",
            "贵州",	"六盘水",	"遵义",	"铜仁",	"毕节",	"贵阳",
            "云南",	"昆明",	"曲靖",	"玉溪",	"保山",	"昭通",	"丽江",	"临沧",	"文山",	"红河",
            "西双版纳","楚雄",	"大理",	"德宏",	"怒江",	"迪庆",
            // 东北地区	辽宁、吉林、黑龙江、蒙东
            "辽宁",	"沈阳",	"大连",	"鞍山",	"抚顺",	"本溪",	"丹东",	"锦州",	"营口",	"阜新",
            "辽阳",	"盘锦",	"铁岭",	"葫芦岛",
            "吉林",	"延边",	"长春",	"松原",	"白城",	"通化",	"长白山",	"吉林",	"辽源",	"四平",
            "安徽",	"合肥",	"芜湖",	"蚌埠",	"马鞍山",	"淮北",	"铜陵",	"安庆",	"黄山",	"滁州",
            "阜阳",	"宿州",	"巢湖",	"六安",	"池州",	"宣城",
            "黑龙江",	"哈尔滨",	"齐齐哈尔","牡丹江",	"佳木斯",	"大庆",	"鸡西",	"伊春",	"双鸭山",	"七台河",
            "鹤岗",	"黑河",	"绥化",	"大兴安岭",
    };
    public static void ignoreSSLHandshake() {
        try {
            TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
                public X509Certificate[] getAcceptedIssuers() {
                    return new X509Certificate[0];
                }

                @Override
                public void checkClientTrusted(X509Certificate[] certs, String authType) {
                }

                @Override
                public void checkServerTrusted(X509Certificate[] certs, String authType) {
                }
            }};

            SSLContext sc = SSLContext.getInstance("TLS");
            // trustAllCerts信任所有的证书
            sc.init(null, trustAllCerts, new SecureRandom());
            HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
            HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
                @Override
                public boolean verify(String hostname, SSLSession session) {
                    return true;
                }
            });
        } catch (Exception e) {
        }
    }

}
